//app.js
App({
  onLaunch: function () {
    wx.getSystemInfo({ //  获取页面的有关信息
      success: function (res) {
        wx.setStorageSync('systemInfo', res)
        console.log(res)
        let model = res.model
        if (model.search('iPhone X') != -1) {
          wx.setStorageSync('iphoneX', "in")
        } else {
          wx.setStorageSync('iphoneX', "out")
        }
      }
    });
    this.getSetting()
  },
  globalData: {
    userInfo: null,
    hh: null,
    //改变量用户存放全局变量修改过程中的值传递, 传递对象
    data: {}
  },
  getSetting() {
    wx.getSetting({
      success: (res) => {
        console.log(JSON.stringify(res))
        if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {
          wx.showModal({
            title: '请求授权当前位置',
            content: '需要获取您的地理位置，请确认授权',
            success: function (res) {
              if (res.cancel) {
                wx.showToast({
                  title: '拒绝授权',
                  icon: 'none',
                  duration: 1000
                })
              } else if (res.confirm) {
                wx.openSetting({
                  success: function (dataAu) {
                    if (dataAu.authSetting["scope.userLocation"] == true) {
                      wx.showToast({
                        title: '授权成功',
                        icon: 'success',
                        duration: 1000
                      })
                      //再次授权，调用wx.getLocation的API

                    } else {
                      wx.showToast({
                        title: '授权失败',
                        icon: 'none',
                        duration: 1000
                      })
                    }
                  }
                })
              }
            }
          })
        } else if (res.authSetting['scope.userLocation'] == undefined) {
          //调用wx.getLocation的API
        } else {
          //调用wx.getLocation的API
        }
      }
    })
  }
  //app.js
})